﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace park.ModelCode
{
    public partial class DictionaryList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string method = Request.Params["method"];
                if (!string.IsNullOrEmpty(method))
                {
                    switch (method)
                    {
                        case "GetListDictionary":
                            PrintResult();
                            break;
                        case "DelDictionary":
                            PrintDelResult();
                            break;
                        default:
                            Response.End();
                            break;
                    }

                }
            }
        }


        private void PrintDelResult()
        {

            #region 正式代码
            string strID = Request.Params["ID"];

            cn.linkit.epark.ServiceList sl = new cn.linkit.epark.ServiceList();

            bool result = sl.DelDictionary(strID);

            if (result)
            {
                Response.Write("{\"ListSensor\":\"删除成功\"}");
                Response.End();
            }
            else
            {
                Response.Write("{\"ListSensor\":\"删除失败\"}");
                Response.End();
            }
            #endregion

            #region 测试代码
            //string sensorId = Request.Params["ID"];

            //bool result = true;

            //if (result)
            //{
            //    Response.Write("{\"DelDictionary\":\"删除成功\"}");
            //    Response.End();
            //}
            //else
            //{
            //    Response.Write("{\"DelDictionary\":\"删除失败\"}");
            //    Response.End();
            //}
            #endregion


        }

        private void PrintResult()
        {

            #region 正式代码
            string strName = Request.Params["Name"];
            int page = int.Parse(Request.Params["page"]);
            int size = int.Parse(Request.Params["size"]);

            cn.linkit.epark.ServiceList sl = new cn.linkit.epark.ServiceList();

            string json = sl.GetListDictionary(strName, page, size);

            Response.Write(json);
            Response.End();
            #endregion

            #region 测试代码
            //int total = 100;
            //string result = ""
            //    + "[{"
            //    + "\"ID\": 2,"
            //    + "\"Name\": \"调度巡检记录\","
            //    + "\"ContentItem\": \"已处理   贴罚单   误报   逃逸    特许车\""
            //    + "},"
            //    + "{"
            //    + "\"ID\": 2,"
            //    + "\"Name\": \"调度巡检记录\","
            //    + "\"ContentItem\": \"已处理   贴罚单   误报   逃逸    特许车\""
            //    + "}]";
            //string json = string.Empty;

            //json = "{\"ListDictionary\":" + result + ",\"RowsCount\":" + total + "}";

            //Response.Write(json);
            //Response.End();
            //测试代码---------------------------
            #endregion


        }
    }
}